import React, { useState, useEffect } from 'react';
import styles from './index.less';

import { useOktaAuth } from '@okta/okta-react';

export default function() {
  const { authState, oktaAuth } = useOktaAuth();

  const obj = useOktaAuth();
  console.log(obj);

  const login = async () => {
    await oktaAuth.signInWithRedirect();
  };

  useEffect(() => {
    console.log;
  }, [authState, oktaAuth]);

  return (
    <div>
      11111
      <div>
        <h1>欢迎来到我的应用！</h1>
        {authState && authState.isAuthenticated ? (
          <p>你已登录</p>
        ) : (
          <button onClick={login}>登录</button>
        )}
      </div>
    </div>
  );
}
